package main

import (
	"context"
	"fmt"
	"github.com/apache/rocketmq-client-go/v2"
	"github.com/apache/rocketmq-client-go/v2/primitive"
	"github.com/apache/rocketmq-client-go/v2/producer"
)

func main() {
	p, _ := rocketmq.NewProducer(
		producer.WithNsResolver(primitive.NewPassthroughResolver([]string{"127.0.0.1:9876"})),
		producer.WithRetry(2),
	)
	err := p.Start()
	if err != nil {
		panic("Start failed")
	}
	//msg := &primitive.Message{
	//			Topic: topic,
	//			Body:  []byte("Hello RocketMQ Go Client! " + strconv.Itoa(i)),
	//		}
	//		res, err := p.SendSync(context.Background(), msg)

	msg := &primitive.Message{
		Topic: "mqtest",
		Body:  []byte("@@@@@@@@@"),
	}
	sync, err := p.SendSync(context.Background(), msg)
	if err != nil {
		panic("SendSync failed")
	}
	fmt.Printf("result: %v\n", sync.String())
	fmt.Printf("send resutl \n", sync)

	p.Shutdown()

}
